
import { defineStore } from 'pinia'
import cache from '@/plugins/cache'
const storeKey = 'layout-bigScreen'
const storageSetting = JSON.parse(cache.local.get(storeKey)) || {}
export const useCounterStore = defineStore('main', {
  state: () => ({
    theme: storageSetting.theme || 'linear-gradient(#042BAA, #255CC3)',
    icon: storageSetting.icon || 'ty',
    echartsTheme: storageSetting.echartsTheme || 'themeD'
  }),
  actions: {
    increment(styleObj) {
      this.theme = styleObj.theme
      this.icon = styleObj.icon
    },
    changeSetting() {
      cache.local.set(storeKey, JSON.stringify(this.$state))
    },
    changeEchartsTheme(value) {
      this.echartsTheme = value
    }

  }
})

// pinia不需要mutation，只需要使用action来改变状态
